//---------------- config
var api_url='//api.maigutec.com/api/site'; //末尾无/   http://api.local.maigutec.com:8010/site   //api.maigutec.com/api/site
var cdn_site='//oss2.damaicn.cn'; //末尾无/
var cdn_static='//public.cdn.viposs.com'; //末尾无/
var cdn_attachment='//s0.cdn.viposs.com/'; //末尾有/
var AK="HkdiD";
var SK="a9bd8e249e15568e20fa2fa4d93941e116cb7ee5";

//---------------- 自定义程序（基本程序）
//图片水平轮播
function imgScroll(objn, scrollSpeed) {
    var obj = document.getElementById(objn);
    var obj1 = document.getElementById(objn + "_1");
    var obj2 = document.getElementById(objn + "_2");
    obj2.innerHTML = obj1.innerHTML;
    function Marquee1() {
        if (obj2.offsetWidth - obj.scrollLeft <= 0) {
            obj.scrollLeft -= obj1.offsetWidth;
        } else {
            obj.scrollLeft++;
        }
    };
    function Marquee2() {
        clearInterval(MyMar1);
        if (obj2.offsetWidth - obj.scrollLeft >= 0) {
            obj.scrollLeft += obj1.offsetWidth;
        } else {
            obj.scrollLeft--;
        }
        MyMar1 = setInterval(Marquee2, scrollSpeed)
    };
    var MyMar1 = setInterval(Marquee1, scrollSpeed);
    obj.onmouseover = function() {
        clearInterval(MyMar1);
    };
    obj.onmouseout = function() {
        MyMar1 = setInterval(Marquee1, scrollSpeed);
    };
}

//图片自动缩小
function autoThumb(ImgD, W, H) {
    var image = new Image();
    var iwidth = W;
    var iheight = H;
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= iwidth / iheight) {
            if (image.width > iwidth) {
                ImgD.width = iwidth;
                ImgD.height = (image.height * iwidth) / image.width;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        } else {
            if (image.height > iheight) {
                ImgD.height = iheight;
                ImgD.width = (image.width * iheight) / image.height;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
}

//图片自动缩小（自适应）
function vcms_imgWidthReSet(obj,max_witdh){
    try{
        obj.css("width","");
        obj.css("height","");
        obj.attr("width","");
        obj.attr("height","");
        obj.css('max-width',max_witdh);
    }
    catch(err){alert('js err: vcms_imgWidthReSet');}
}

//---------------- 自定义程序（高级程序）
//获取验证码
function get_scode(obj,img) {
    //获取随机字符串
    vcms_getJSON({
        action:'get_nonce_string',
        opts:'&from=1',
        success:function(res){
            if(res.err_code==0){
                $("#" +obj).val(res.data);
                //获取验证码
                vcms_getJSON({
                    action:'get_vercode',
                    opts:'&word='+encodeURIComponent(res.data),
                    success:function(res2){
                        if(res2.err_code==0){
                            $("#" + img).html('<canvas id="vcms-scode-image" width="120" height="33" style="cursor: pointer; background-color: #fff; vertical-align: middle;" title="看不清？点击换一个"></canvas>');
                            canvas_draw('vcms-scode-image',res2.data);
                        }else{
                            layer.msg(res2.err_msg);
                        }
                    },
                });
            }else{
                layer.msg(res.err_msg);
            }
        },
    });
}

//用于发布信息到文档
function submit_artical(opts){
    var err_code=0;
    var err_msg='';
    //开始验证
    for(var i=0;i<opts.data.form.submit.check.length;i++){
        var value=$("#"+opts.data.form.list.name+opts.data.form.submit.check[i]).val();
        if(value!=''){
            value=value.replace(/\s+/g,'');
        }
        if(value==''){
            layer.alert(opts.data.form.submit.err_msg[i]);
            err_code=1;
            break;
        }
    }
    //验证码
    if(err_code==0){
        var value=$("#scode").val();
        if(value!=''){
            value=value.replace(/\s+/g,'');
        }
        if(value==''){
            switch(opts.data.lan){
                case 1: err_msg='请填写验证码'; break;
                case 2: err_msg='Please input the validate codes'; break;
            }
            layer.alert(err_msg);
            err_code=1;
        }
    }
    //开始提交
    if(err_code==0){
        switch(opts.data.lan){
            case 1: err_msg='数据提交中...'; break;
            case 2: err_msg='Data is being submitted...'; break;
        }
        layer.msg(err_msg);
        //准备数据
        var opts2={
            AK:AK,
            SK:SK,
            projects:[
                {
                    project:'set_artical',
                    para:{
                        scode:$("#scode").val(),
                        scode2:$("#scode2").val(),
                        item_id:opts.data.item.id,
                        artical:{
                            title:opts.data.artical.title,
                        },
                        append:[],
                        submit_mode:opts.data.submit_mode,
                    },
                },
            ],
            from:1, //前端跨域
        };
        for(var i=1;i<=opts.data.form.list.count;i++){
            opts2.projects[0].para.append.push($("#"+opts.data.form.list.name+i).val());
        }
        //提交数据
        vcms_getJSON({
            action:'console',
            opts:'&opts='+encodeURIComponent(JSON.stringify(opts2)),
            success:function(res){
                if(res.err_code==0){
                    var this_res=res.dataset[0];
                    if(this_res.err_code==0){
                        layer.msg('恭喜您的信息提交成功！');
                        if(typeof(opts.success) === 'function'){
                            opts.success(res);
                        }
                    }else{
                        layer.msg(this_res.err_msg);
                    }
                }else{
                    layer.msg(res.err_msg);
                }
            },
        });
    }
}

//发布留言或评论
function submit_message(opts) {
    var err_code=0;
    var err_msg='';
    //开始验证
    for(var i=0;i<opts.form.submit.check.length;i++){
        var value=$("#"+opts.form.submit.check[i]).val();
        console.log(value)
        if(value!=''){
            value=value.replace(/\s+/g,'');
        }
        if(value==''){
            layer.alert(opts.form.submit.err[i]);
            err_code=1;
            break;
        }
    }
    //验证码
    if(err_code==0){
        var value=$("#scode").val();
        if(value!=''){
            value=value.replace(/\s+/g,'');
        }
        if(value==''){
            switch(opts.form.lan){
                case 1: err_msg='请填写验证码'; break;
                case 2: err_msg='Please input the validate codes'; break;
            }
            layer.alert(err_msg);
            err_code=1;
        }
    }
    //开始提交
    if(err_code==0) {
        switch (opts.form.lan) {
            case 1:
                err_msg = '数据提交中...';
                break;
            case 2:
                err_msg = 'Data is being submitted...';
                break;
        }
        layer.msg(err_msg);
        var opts2={
            AK:AK,
            SK:SK,
            projects:[
                {
                    project:'set_message',
                    para:opts.data,
                },
            ],
            from:1, //前端跨域
        };
        console.log(opts2)
        vcms_getJSON({
            action:'console',
            opts:'&opts='+encodeURIComponent(JSON.stringify(opts2)),
            success:function(res){
                if(typeof(opts.success) === 'function'){
                    opts.success(res);
                }
            },
        });
    }
}

//用于提交信息到指定邮箱
function submit_email(opts){
    var opts2={
        AK:AK,
        SK:SK,
        projects:[
            {
                project:'send_email',
                para:opts.data,
            },
        ],
        from:1, //前端跨域
    };
    var loader = layer.load(2);
    vcms_getJSON({
        action:'console',
        opts:'&opts='+encodeURIComponent(JSON.stringify(opts2)),
        success:function(res){
            layer.close(loader);
            if(parseInt(res.err_code)==0){
                if(typeof(opts.success) === 'function'){
                    layer.msg('发送成功',{time:1200});
                    opts.success(res);
                }
            }else{
                layer.msg(res.err_msg,{time:1200});
            }
        },
    });
}

//用于发送短信
function submit_sms_juhe(opts){
    var opts2={
        AK:AK,
        SK:SK,
        projects:[
            {
                project:'send_sms_juhe',
                para:opts.data,
            },
        ],
        from:1, //前端跨域
    };
    var loader = layer.load(2);
    console.log(opts2)
    vcms_getJSON({
        action:'console',
        opts:'&opts='+encodeURIComponent(JSON.stringify(opts2)),
        success:function(res){
            layer.close(loader);
            if(parseInt(res.err_code)==0){
                if(typeof(opts.success) === 'function'){
                    opts.success(res);
                }
            }else{
                layer.msg(res.err_msg,{time:1200});
            }
        },
    });
}

//自定义弹出层
function vcms_dialog_open() {
    layui.use(['form','layer'], function(){
        var form = layui.form;
        var layer = layui.layer;
        //
        $(".dialog_open").on('click',function(){
            var init=$(this).attr("alt").split(",");
            var opts={
                action: init[0],
                data:{
                    site:{
                        id:init[1],
                    },
                    artical:{
                        id:0,
                    },
                    member:{
                        id:0,
                    },
                },
                submit_mode: init[2],
                lan: init[3],
                dialog: {
                    title:'',
                },
                form:{
                    list_label:[],
                    list_id:[],
                    list_placeholder:[],
                    list_input:[],
                    list_input_class:[],
                    require_id:[],
                    scode_label:'验证码',
                    scode_tip:'点击获取验证码',
                    scode_err_msg:'请填写验证码',
                    submit_label:'确定发布',
                },
            };
            //数据赋值
            if(opts['action']='message'){
                opts['form']['list_name']=['name','address','mobile','email','weixin','qq','message'];
                opts['form']['list_input']=[1,1,1,1,1,1,2]; //控件类型
                opts['form']['list_input_class']=['','','','input_email','','','']; //特殊控件定义
                opts['form']['require_id']=['name','mobile','message']; //提交时要检测的控件编号
                if(opts['lan']==1){
                    opts['dialog']['title']='留言板';
                    opts['form']['list_label']=['您的称呼','联系地址','手机号码','电子邮箱','微信号','QQ 号码','留言内容'];
                    opts['form']['list_verify']=['required','','phone','','','','required'];
                    opts['form']['list_placeholder']=['必填','','必填','','','','必填，最多200字'];
                }else if(opts['lan']==2){
                    opts['dialog']['title']='Leave Message';
                    opts['form']['list_label']=['Your Name','Address','Phone','Email','WeChat','MSN','Message'];
                    opts['form']['list_verify']=['required','','phone','','','','required'];
                    opts['form']['list_placeholder']=['not null','','not null','','','','not null'];
                }
            }
            //
            if(opts['lan']==2) {
                opts['form']['submit_label']='SUBMIT';
                //验证码
                opts['form']['scode_label']='Security code';
                opts['form']['scode_tip']='Get code';
                opts['form']['scode_err_msg']='Please input the security code';
            }
            //控件列表
            var vcms_form_items='';
            var vcms_form_item='';
            for(var i=0;i<opts['form']['list_name'].length;i++){
                switch(opts['form']['list_input'][i]){
                    case 1: vcms_form_item='<input type="text" name="'+opts['form']['list_name'][i]+'" maxlength="20" class="layui-input" lay-verify="'+opts['form']['list_verify'][i]+'" placeholder="'+opts['form']['list_placeholder'][i]+'" autocomplete="off" />'; break;
                    case 2: vcms_form_item='<textarea name="'+opts['form']['list_name'][i]+'" class="layui-textarea" lay-verify="'+opts['form']['list_verify'][i]+'" placeholder="'+opts['form']['list_placeholder'][i]+'" autocomplete="off"></textarea>'; break;
                }
                vcms_form_items+='<div class="layui-form-item">' +
                    '<label class="layui-form-label">'+opts['form']['list_label'][i]+'：</label>' +
                    '<div class="layui-input-block">'+vcms_form_item+'</div>' +
                    '</div>';
            }
            //
            var vcms_form_id='layui-vcms-form-dialog';
            var vcms_form_submit_id='layui-vcms-form-dialog-submit';
            var string='<div id="vcms-dialog" style="padding: 30px;">' +
                '<form action="" class="layui-form" id="'+vcms_form_id+'" lay-filter="'+vcms_form_id+'">' +
                vcms_form_items +

                '<div class="layui-form-item">' +
                '<label class="layui-form-label">'+opts['form']['scode_label']+'：</label>' +
                '<div class="layui-input-block">' +
                '<input type="text" name="scode" id="scode" maxlength="20" lay-verify="required" class="layui-input" style="width:100px; float: left;" /> ' +
                '<input type="hidden" name="scode2" id="scode2" value="" />' +
                '<div id="scode_image" style="float: left;" class="click">'+opts['form']['scode_tip']+'</div>' +
                '</div>' + //layui-input-block
                '</div>' + //layui-form-item

                '<div class="layui-form-item"> ' +
                '<div class="layui-input-block"><button class="layui-btn layui-btn-danger" lay-submit lay-filter="'+vcms_form_submit_id+'">'+opts['form']['submit_label']+'</button></div> ' +
                '</div>' + //layui-form-item
                '</form>' +
                '</div>';
            var w=$(window).width();
            if(w<768){
                var area=['96%', '96%'];
            }else{
                var area=['600px', '60%'];
            }
            layer.open({
                type: 1,
                skin: '',
                closeBtn: 1,
                area: area,
                shadeClose: false,
                title: opts['dialog']['title'],
                content: string,
                success: function (layero, layer_index) {
                    form.render(null, vcms_form_id);
                    //获取验证码
                    get_scode('scode2','scode_image');
                    $("#scode_image").click(function(){
                        get_scode('scode2','scode_image');
                    });
                    //提交
                    form.on('submit('+vcms_form_submit_id+')', function(form_data){
                        var fields=form_data.field;
                        var submit_data={
                            site:{
                                id:opts.data.site.id,
                            },
                            artical:{
                                id:opts.data.artical.id,
                            },
                            member:{
                                id:opts.data.member.id,
                                name:fields.name,
                                gender:'',
                                address:fields.address,
                                mobile:fields.mobile,
                                email:fields.email,
                                weixin:fields.weixin,
                                qq:fields.qq,
                            },
                            message:{
                                to:0,
                                message:fields.message,
                                referer:'',
                                show_mode:opts.submit_mode,
                            },
                            scode:fields.scode,
                            scode2:fields.scode2,
                        };
                        //
                        if(opts['action']='message'){
                            submit_message({
                                data:submit_data,
                                success:function(res){
                                    if(res.err_code==0){
                                        var this_res=res.dataset[0];
                                        if(this_res.err_code==0){
                                            layer.msg('恭喜您的信息提交成功！',{time:1200});
                                            layer.close(layer_index);
                                            window.setTimeout(
                                                function(){window.location.href=window.location.href;},
                                                1000
                                            );
                                        }else{
                                            layer.msg(this_res.err_msg,{time:1200});
                                        }
                                    }else{
                                        layer.msg(res.err_msg,{time:1200});
                                    }
                                }
                            });
                        }
                        return false;
                    });
                }
            });
        });
    });
}

//文字点击率更新
function vcms_artical_hit(){
    var id=parseInt($("#hit").attr("_id"));
    $("#hit").html('0');
    if (id!=0){
        vcms_getJSON({
            action:'act_artical_hit',
            opts:'&id='+id,
            success:function(res){
                if(parseInt(res.err_code)==0){
                    $("#hit").html(res.data.hit);
                }
            },
        });
    }
}

//获取点赞
function vcms_get_artical_like(data){
    if (data['id']!=""){
        if(!isNaN(data['id'])){
            vcms_getJSON({
                action:'get_artical_like',
                opts:'&id='+data['id'],
                success:function(res){
                    if(parseInt(res.err_code)==0){
                        if(res.data.total!=0){
                            $(data['obj']).html(res.data.total);
                        }
                    }
                },
            });
        }
    }
}

//点赞更新
function vcms_artical_like(data){
    if (data['id']!=""){
        if(!isNaN(data['id'])){
            vcms_getJSON({
                action:'act_artical_like',
                opts:'&id='+data['id'],
                success:function(res){
                    if(parseInt(res.err_code)==0){
                        if(res.data.total!=0){
                            $(data['obj']).html(res.data.total);
                            layer.msg('谢谢亲',{time:800});
                        }
                    }else{
                        layer.msg(res.err_msg,{time:1200});
                    }
                },
            });
        }
    }
}

//获取评论数
function vcms_get_artical_comment_count(data){
    if (data['id']!=""){
        if(!isNaN(data['id'])){
            vcms_getJSON({
                action:'get_message_count',
                opts:'&id='+data['id'],
                success:function(res){
                    if(parseInt(res.err_code)==0){
                        if(res.data.total!=0){
                            $(data['obj']).html(res.data.total);
                        }
                    }
                },
            });
        }
    }
}

//文章评论提交
function vcms_artical_comment(opts){
    layui.use(['form','layer'], function() {
        var form = layui.form;
        var layer = layui.layer;
        var w=$(window).width();
        //面板
        var string='<div id="vcms-layer-container" class="vcms-layer-container">' +
            '<div id="vmcs-artical-comment-list"></div>' +
            '<div style="text-align: center"><button type="button" class="layui-btn layui-btn-danger vcms-btn-comment-add">我要点评</button></div> ' +
            '</div>';
        //
        if(w<768){
            var area=['96%', '96%'];
        }else{
            var area=['800px', '60%'];
        }
        layer.open({
            type: 1,
            skin: '',
            closeBtn: 1,
            area: area,
            shadeClose: true,
            title: opts['dialog']['title'],
            content: string,
            success: function (layero, layer_index) {
                //初始加载
                get_comment_list();
                //添加
                $('.vcms-btn-comment-add').click(function(){
                    var vcms_form_id='layui-vcms-form-comment';
                    var vcms_form_submit_id='layui-vcms-form-comment-submit';
                    var string='<div style="padding: 20px;">' +
                        '<form action="" class="layui-form" id="'+vcms_form_id+'" lay-filter="'+vcms_form_id+'">' +
                        '<div class="layui-form-item">' +
                        '<label class="layui-form-label">您的称呼</label>' +
                        '<div class="layui-input-inline"><input type="text" class="layui-input" name="name" lay-verify="required" placeholder="必填" autocomplete="off"></div>' +
                        '</div>' + //layui-form-item
                        '<div class="layui-form-item">' +
                        '<label class="layui-form-label">手机号码</label>' +
                        '<div class="layui-input-inline"><input type="text" class="layui-input" name="mobile" lay-verify="phone"  placeholder="必填" autocomplete="off"></div>' +
                        '</div>' + //layui-form-item
                        '<div class="layui-form-item">' +
                        '<label class="layui-form-label">评论内容</label>' +
                        '<div class="layui-input-block"><textarea class="layui-textarea" name="message" lay-verify="required" autocomplete="off"  placeholder="必填"></textarea></div>' +
                        '</div>' + //layui-form-item
                        '<div class="layui-form-item">' +
                        '<label class="layui-form-label">验证码</label>' +
                        '<div class="layui-input-block">' +
                        '<input type="text" id="scode" name="scode" maxlength="20" lay-verify="required" class="layui-input" style="width:100px; float: left;" /> ' +
                        '<input type="hidden" id="scode2" name="scode2" value="" />' +
                        '<div id="scode_image" style="float: left;" class="click">点击获取</div>' +
                        '</div>' + //layui-input-block
                        '</div>' + //layui-form-item
                        '<div class="layui-form-item"> ' +
                        '<div class="layui-input-block"><button class="layui-btn layui-btn-danger" lay-submit lay-filter="'+vcms_form_submit_id+'">发布评论</button></div> ' +
                        '</div>' + //layui-form-item
                        '</form>' +
                        '</div> ';
                    if(w<768){
                        var area=['90%', '90%'];
                    }else{
                        var area=['600px', '50%'];
                    }
                    layer.open({
                        type: 1,
                        skin: '',
                        closeBtn: 1,
                        area: area,
                        shadeClose: false,
                        title: '发布点评',
                        content: string,
                        success: function (layero, layer2_index) {
                            form.render(null, vcms_form_id);
                            //获取验证码
                            get_scode('scode2','scode_image');
                            $("#scode_image").click(function(){
                                get_scode('scode2','scode_image');
                            });
                            //提交
                            form.on('submit('+vcms_form_submit_id+')', function(form_data){
                                var fields=form_data.field;
                                var submit_data={
                                    site:{
                                        id:opts.data.site_id,
                                    },
                                    artical:{
                                        id:opts.data.artical_id,
                                    },
                                    member:{
                                        id:0,
                                        name:fields.name,
                                        gender:'',
                                        address:'',
                                        mobile:fields.mobile,
                                        email:'',
                                        weixin:'',
                                        qq:'',
                                    },
                                    message:{
                                        to:0,
                                        message:fields.message,
                                        referer:'',
                                        show_mode:opts.data2.submit_mode,
                                    },
                                    scode:fields.scode,
                                    scode2:fields.scode2,
                                };
                                //
                                if(opts['action']='message'){
                                    submit_message({
                                        data:submit_data,
                                        success:function(res){
                                            if(res.err_code==0){
                                                var this_res=res.dataset[0];
                                                if(this_res.err_code==0){
                                                    layer.msg('恭喜您的信息提交成功！',{time:1200});
                                                    layer.close(layer2_index);
                                                    get_comment_list();
                                                }else{
                                                    layer.msg(this_res.err_msg,{time:1200});
                                                }
                                            }else{
                                                layer.msg(res.err_msg,{time:1200});
                                            }
                                        }
                                    });
                                }
                                return false;
                            });
                        }
                    });
                });
                //程序
                function get_comment_list(){
                    vcms_getJSON({
                        action:'get_message_list',
                        opts:'&opts='+encodeURIComponent(JSON.stringify(opts['data'])),
                        success:function(res){
                            if(parseInt(res.err_code)==0){
                                var str='';
                                if(res.data.list.length==0){
                                    str='<div style="width: 100%; text-align: center; padding-bottom: 15px; overflow: hidden; color: #999;">暂无评论</div>';
                                }else{
                                    str='<ul class="vcms-artical-comment-list">';
                                    for(var i=0;i<res.data.list.length;i++){
                                        str+='<li>';
                                        str+='<div class="d1"><em>评论时间：'+res.data.list[i].time+'</em>网友称呼：'+res.data.list[i].member.name+'</div>';
                                        str+='<div class="d2">'+res.data.list[i].message+'</div>';
                                        if(res.data.list[i].reply!=''){
                                            str+='<div class="d3">回复内容：';
                                            str+=res.data.list[i].reply+'（回复时间：'+toTime(res.data.list[i].reply_time,2)+'）';
                                            str+='</div>';
                                        }
                                        str+='</li>';
                                    }
                                    str+='</ul>';
                                }
                                $('#vmcs-artical-comment-list').html(str);
                            }else{
                                layer.msg(this_res.err_msg,{time:1200});
                            }
                        },
                    });
                }
            }
        });
    });
}

//获取省市
function vcms_get_city(opts){
    vcms_getJSON({
        action:'get_city_list',
        opts:'&to='+opts.to+'&from=1',
        success:function(res){
            if(typeof(opts.success) === 'function'){
                opts.success(res);
            }
        },
    });
}

//---------------- 自定义程序（公共）

/*画图*/
function canvas_draw(obj,str) {
    var canvas_width=$('#'+obj).width();
    var canvas_height=$('#'+obj).height();
    var canvas = document.getElementById(obj);//获取到canvas的对象，演员
    var context = canvas.getContext("2d");//获取到canvas画图的环境，演员表演的舞台
    canvas.width = canvas_width;
    canvas.height = canvas_height;
    for (var i = 0; i < str.length; i++) {
        var deg = Math.random() * 30 * Math.PI / 180;//产生0~30之间的随机弧度
        var txt = str[i];//得到随机的一个内容
        var x = 10 + i * 20;//文字在canvas上的x坐标
        var y = 20 + Math.random() * 8;//文字在canvas上的y坐标
        context.font = "bold 23px 微软雅黑";
        context.translate(x, y);
        context.rotate(deg);
        context.fillStyle = canvas_draw_randomColor();
        context.fillText(txt, 0, 0);
        context.rotate(-deg);
        context.translate(-x, -y);
    }
    for (var i = 0; i <= 5; i++) { //验证码上显示线条
        context.strokeStyle = canvas_draw_randomColor();
        context.beginPath();
        context.moveTo(Math.random() * canvas_width, Math.random() * canvas_height);
        context.lineTo(Math.random() * canvas_width, Math.random() * canvas_height);
        context.stroke();
    }
    for (var i = 0; i <= 30; i++) { //验证码上显示小点
        context.strokeStyle = canvas_draw_randomColor();
        context.beginPath();
        var x = Math.random() * canvas_width;
        var y = Math.random() * canvas_height;
        context.moveTo(x, y);
        context.lineTo(x + 1, y + 1);
        context.stroke();
    }
    function canvas_draw_randomColor(){//得到随机的颜色值
        var r = Math.floor(Math.random() * 256);
        var g = Math.floor(Math.random() * 256);
        var b = Math.floor(Math.random() * 256);
        return "rgb(" + r + "," + g + "," + b + ")";
    }
}

/*getJSON*/
function vcms_getJSON(opts){
    var url=api_url+'/?action='+opts.action+opts.opts+'&callback=?';
    $.getJSON(url,function(res){
        if(typeof(opts.success) === 'function'){
            opts.success(res);
        }
    });
}

